package gemini.castor.ui.client.page;

import gemini.basic.model.User;

import com.google.gwt.event.shared.GwtEvent;

public class RootEvent extends GwtEvent<RootHandler> {

	private static Type<RootHandler> TYPE;
	
	public static Type<RootHandler> getType() {
		if (TYPE == null)
			TYPE = new Type<RootHandler>();
		return TYPE;
	}
	
	private User user;
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public enum ForwardType {
		MASK, UN_MASK;
	}
	
	public RootEvent(ForwardType forwardType) {
		super();
		this.setForwardType(forwardType);
	}
	
	private ForwardType forwardType;
	
	@Override
	protected void dispatch(RootHandler handler) {
		if(forwardType.equals(ForwardType.MASK)){
			handler.onMask(this);
		} else if(forwardType.equals(ForwardType.UN_MASK)){
			handler.onUnMask(this);
		}
	}
	
	@Override
	public Type<RootHandler> getAssociatedType() {
		return getType();
	}

	public void setForwardType(ForwardType forwardType) {
		this.forwardType = forwardType;
	}

	public ForwardType getForwardType() {
		return forwardType;
	}

}
